<html>
<head><meta charset="utf-8"><title>two phase borrows · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two.20phase.20borrows.html">two phase borrows</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="148294017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two%20phase%20borrows/near/148294017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two.20phase.20borrows.html#148294017">(Nov 24 2018 at 22:43)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ca90a070470c1557fa2bffa5017e8ff1" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ca90a070470c1557fa2bffa5017e8ff1">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ca90a070470c1557fa2bffa5017e8ff1</a></p>



<a name="148311400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two%20phase%20borrows/near/148311400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two.20phase.20borrows.html#148311400">(Nov 25 2018 at 09:05)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> thanks! miri chokes on it ;)</p>



<a name="148315014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two%20phase%20borrows/near/148315014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two.20phase.20borrows.html#148315014">(Nov 25 2018 at 11:17)</a>:</h4>
<p>Also: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=e6171b97de9eb7e3fab2e8c73757da1f" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=e6171b97de9eb7e3fab2e8c73757da1f">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=e6171b97de9eb7e3fab2e8c73757da1f</a></p>



<a name="148326023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two%20phase%20borrows/near/148326023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two.20phase.20borrows.html#148326023">(Nov 25 2018 at 17:33)</a>:</h4>
<p>thanks!</p>



<a name="148364383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two%20phase%20borrows/near/148364383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two.20phase.20borrows.html#148364383">(Nov 26 2018 at 12:40)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2015&amp;gist=91ad3ea6ef3c07e8b0b3a8c6301af600" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2015&amp;gist=91ad3ea6ef3c07e8b0b3a8c6301af600">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2015&amp;gist=91ad3ea6ef3c07e8b0b3a8c6301af600</a><br>
<a href="https://gist.github.com/91ad3ea6ef3c07e8b0b3a8c6301af600" target="_blank" title="https://gist.github.com/91ad3ea6ef3c07e8b0b3a8c6301af600">https://gist.github.com/91ad3ea6ef3c07e8b0b3a8c6301af600</a></p>



<a name="148364603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two%20phase%20borrows/near/148364603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two.20phase.20borrows.html#148364603">(Nov 26 2018 at 12:46)</a>:</h4>
<p>and without IM:</p>
<div class="codehilite"><pre><span></span><span class="k">use</span><span class="w"> </span><span class="n">std</span>::<span class="n">ops</span>::<span class="n">AddAssign</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">l</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">x</span><span class="p">;</span><span class="w"></span>
<span class="n">x</span><span class="w">                   </span><span class="c1">// (1)</span>
<span class="w">    </span><span class="p">.</span><span class="n">add_assign</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="n">x</span><span class="w">  </span><span class="c1">// (2)</span>
<span class="w">        </span><span class="o">+</span><span class="w"></span>
<span class="w">        </span><span class="o">*</span><span class="n">l</span><span class="w"> </span><span class="c1">// (4)</span>
<span class="p">)</span><span class="w">                   </span><span class="c1">// (3)</span>
<span class="p">;</span><span class="w"></span>
</pre></div>



<a name="148364610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two%20phase%20borrows/near/148364610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/two.20phase.20borrows.html#148364610">(Nov 26 2018 at 12:46)</a>:</h4>
<p>related issue: <a href="https://github.com/rust-lang/rust/issues/53198" target="_blank" title="https://github.com/rust-lang/rust/issues/53198">https://github.com/rust-lang/rust/issues/53198</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>